package it.univpm.diiga.memorysim.kernel.shared;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;

public class SimEvent {
	//private int numEvent;
	private String eventType;
	private ProcessRequest process;
	private int time=0;
	private int PID=-1;
	private int pagIn=-2;
	private int pagOut=-2;
	private List<ProcessRequest> processBlock=new ArrayList<ProcessRequest>();
	private List<EmptyBlock> emptyBlock=new ArrayList<EmptyBlock>();
	
	// campi giusti per l'interfaccia
	private Hashtable<Integer, ProcessRequest> StructureMem;   
	private Hashtable<Integer, ProcessRequest> StructureSwap;
	private String fileName=null;
	private String pathName=null;
	private String operation=null;
	
	public SimEvent(int PID,String eventType, int PagIn, int PagOut, Hashtable<Integer, ProcessRequest> Mem, Hashtable<Integer, ProcessRequest> Swap,int time){
		this.PID=PID;
		this.eventType=eventType;
		this.StructureMem=Mem;
		this.StructureSwap=Swap;
		this.pagIn=PagIn;
		this.pagOut=PagOut;
		this.time=time;
	}
	
	public SimEvent(int PID,String eventType, int PagIn, Hashtable<Integer, ProcessRequest> Mem, Hashtable<Integer, ProcessRequest> Swap,int time){
		this.PID=PID;
		this.eventType=eventType;
		this.StructureMem=Mem;
		this.StructureSwap=Swap;
		this.pagIn=PagIn;
		this.time=time;
	}
	
	//harddisk event
	public SimEvent(String fileName,String pathname, String operation,String time){
		this.fileName=fileName;
		this.pathName=pathname;
		this.operation=operation;
		this.time=Integer.parseInt(time);
	}
	
	public String getFileName(){
		return fileName;
	}
	public String getPathName(){
		return pathName;
	}
	
	public String getOpFile(){
		return operation;
	}
	public int getPageIn() {
		return pagIn;
	}
	
	public int getPageOut() {
		return pagOut;
	}
	
	public SimEvent(String eventType,ProcessRequest process){
		//this.numEvent=numEvent;
		this.eventType=eventType;
		this.process=process;
		//this.pagVictim=pagVictim;
		
		//this.processMemory=Parameters.getProcessMemory();
		
		for (int j=0;j<Parameters.getProcessMemory().size();j++){		
			this.processBlock.add((ProcessRequest) Parameters.getProcessMemory().get(j));
		}
		
		for (int j=0;j<Parameters.getEmptyBlockMem().size();j++){		
			this.emptyBlock.add((EmptyBlock) Parameters.getEmptyBlockMem().get(j));
		}
	}
	
	
	/*public int getNumEvent(){
		return this.numEvent;
		
	}*/
	public String getEventType(){
		return this.eventType;
		
	}
	public int getPagEvent(){
		return this.process.getPagina();
		
	}
	
	public int getPID(){
		return this.process.getPID();
		
	}
	
	public int getEventPID(){
		return PID;
		
	}
	
	/*public ProcessRequest getPagVittima(){
		return this.pagVictim;
		
	}*/
	public List<ProcessRequest> getProcessBlock(){
		return this.processBlock;
		
	}
	
	public List<EmptyBlock> getEmptyBlock(){
		return this.emptyBlock;
		
	}
	
	public Hashtable<Integer, ProcessRequest> getStructureMem(){
		return StructureMem;
	}
	
	public Hashtable<Integer, ProcessRequest> getStructureSwap(){
		return StructureSwap;
	}
	
	public int getTime(){
		return time;
	}
	/*public void setEvent(int numEvent, String eventType, ProcessRequest pagEvent, ProcessRequest pagVittima, ArrayList processMemory){
		this.numEvent=numEvent;
		this.eventType=eventType;
		this.pagEvent=pagEvent;
		this.pagVittima=pagVittima;
		this.processMemory=processMemory;
	}*/
	
}
